Skip to content

core: pause/resume primitive for wall-driven auto slab+ceiling sync#336

Merged
wass08 merged 1 commit into
mainfrom
ai/pause-space-detection
May 26, 2026
Merged

core: pause/resume primitive for wall-driven auto slab+ceiling sync#336
wass08 merged 1 commit into
mainfrom
ai/pause-space-detection

Conversation

@wass08
Copy link
Copy Markdown
Collaborator

@wass08 wass08 commented May 26, 2026

What does this PR do?

initSpaceDetectionSync in packages/core/src/lib/space-detection.ts subscribes to every scene mutation and auto-derives slabs/ceilings from wall topology. When a host app drives explicit slab/ceiling creation (e.g. the community editor's AI create_room flow, which builds zone → slab → ceiling → walls in sequence), the auto-sync races those nodes and the polygon-signature de-dupe in syncAuto*ForLevel is fragile enough that duplicate autoFromWalls: true nodes leak through.

This adds a refcount primitive, mirroring pauseSceneHistory in store/history-control.ts:

  • pauseSpaceDetection() / resumeSpaceDetection() / isSpaceDetectionPaused() — exported from @pascal-app/core.
  • The subscriber early-outs while the depth is non-zero, and rolls previousSnapshots forward so resume does NOT backfill paused-period changes (otherwise duplicates just shift in time).

No behavior change for callers that don't touch the new functions. The community editor wires this up via useAISession in a follow-up commit on pascalorg/private-editor.

How to test

  1. From a fresh checkout of this branch: cd packages/core && bun run build && bun test src/lib/space-detection-pause.test.ts — the 4 new unit cases for the refcount should pass.
  2. Confirm nothing else regressed in packages/core: bun test from the core package root. The pre-existing syncAutoStairOpenings failures in src/systems/stair/stair-opening-sync.test.ts (visible on main) are unchanged by this branch.
  3. Smoke-import in a consuming app: import { pauseSpaceDetection, resumeSpaceDetection, isSpaceDetectionPaused } from '@pascal-app/core' — types resolve, runtime calls toggle the depth as expected.

Screenshots / screen recording

N/A — non-visual change (new exports + subscriber gating; no rendering or UI affected).

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run `bun check` to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the `main` branch

initSpaceDetectionSync subscribes to every scene mutation and auto-derives
slabs/ceilings from wall topology. When a host app drives explicit
slab/ceiling creation (e.g. the community editor's AI create_room flow),
the auto-sync races those nodes and the polygon-signature de-dupe is
fragile enough that duplicates leak through.

Expose pauseSpaceDetection / resumeSpaceDetection / isSpaceDetectionPaused
mirroring the existing pauseSceneHistory refcount in store/history-control.
While paused, the subscriber rolls previousSnapshots forward so resume
does NOT trigger a backfill that would re-introduce the very duplicates
the host paused to avoid.

No behavior change for callers that don't touch the new functions.
@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 26, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed May 26, 2026, 7:03 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@wass08 wass08 merged commit 814d943 into main May 26, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant